Những câu hỏi liên quan
Hải Yến Hoàng Thị
Xem chi tiết
Lê Phương Thảo
Xem chi tiết
Nguyễn Lê Phước Thịnh
25 tháng 2 2021 lúc 21:55

uses crt;

var a:array[1..250]of integer;

i,n,dem,t,t1,t2,t3,t4:integer;

begin

clrscr;

repeat

write('Nhap n='); readln(n);

until (0<n) and (n<=250);

for i:=1 to n do 

  begin

repeat

write('A[',i,']='); readln(a[i]);

until (0<a[i]) and (a[i]<=500);

end;

dem:=0;

for i:=1 to n do 

  if a[i] mod 2=1 then inc(dem);

writeln('So phan tu co gia tri le la: ',dem);

t:=0;

for i:=1 to n do 

  if i mod 2=0 then t:=t+a[i];

writeln('Tong cac phan tu co chi so chan la: ',t);

t1:=0;

for i:=1 to n do 

  if i mod 2=1 then t1:=t1+a[i];

writeln('Tong cac phan tu co chi so le la: ',t1);

t2:=0;

for i:=1 to n do 

  if (i mod 2=0) and (a[i] mod 2=0) then t2:=t2+a[i];

writeln('Tong cac phan tu chan co chi so chan la: ',t2);

t3:=0;

for i:=1 to n do 

  if (i mod 2=1) and (a[i] mod 2=1) then t3:=t3+a[i];

writeln('Tong cac phan tu co chi so le la: ',t3);

t4:=0;

for i:=1 to n do 

  t4:=t4+a[i];

writeln('Trung binh cong cac so trong day la: ',t4/n:4:2);

readln;

end.

Bình luận (0)
Lê Văn Tuấn
Xem chi tiết
Dark_Hole
23 tháng 2 2022 lúc 20:58

giờ mình với là gì vậy =)?

Bình luận (3)
Nguyễn Lê Phước Thịnh
24 tháng 2 2022 lúc 13:34

 

Câu 2:

uses crt;

var a:array[1..100]of real;

i,n,dem:integer;

t:real;

begin

clrscr;

randomize;

cin>>n;

for i:=1 to n do a[i]:=random(200);

t:=0; dem:=0;

for i:=1 to n do if a[i]<=150 then begin

t:=t+a[i];

inc(dem);

end;

writeln(t/dem:4:2);

readln;

end.

 

Bình luận (0)
Ngọc Ty
Xem chi tiết
Kiều Vũ Linh
24 tháng 4 2023 lúc 18:56

Var a:array[1..100] of integer;

i,n:integer;

s:longint;

Begin

Write('n = ');readln(n);

For i:=1 to n do

Begin

Write('Nhap phan tu thu ',i,' = ');readln(a[i]);

s:=s+a[i];

End;

Write('Cac phan tu vua nhap la ');

For i:=1 to n do

Write(a[i]:8);

Writeln;

Write('Tong cua chung la ',s);

Readln

End.

Bình luận (0)
APOK FF
Xem chi tiết
Phan uyển nhi
Xem chi tiết
Nguyễn Lê Phước Thịnh
15 tháng 2 2022 lúc 9:49

uses crt;

var a:array[1..100]of integer;

i,n,t,k:integer;

begin

clrscr;

readln(n);

for i:=1 to n do readln(a[i]);

readln(k);

t:=0;

for i:=1 to n do 

  if a[i] mod k=0 then t:=t+a[i];

writeln(t);

readln;

end.

Bình luận (1)
ttanjjiro kamado
15 tháng 2 2022 lúc 9:51

Uses crt;
Var A: array[1..100] of longint;
    n,k,i,s: longint;
Begin
Clrscr;
Write(‘Nhap n,k: ‘); Readln(n,k);
s:=0;
For i:=1 to n do
Begin
Read(A[i]);
If A[i] mod k = 0 then s:=s+A[i];
End;
Write(s);
Readln
End.

Bình luận (1)
Thái Thị Thúy	An
Xem chi tiết
Nguyễn Lê Phước Thịnh
9 tháng 12 2021 lúc 12:27

#include <bits/stdc++.h>

using namespace std;

long long a[200],n,i;

int main()

{

cin>>n;

for (i=1; i<=n; i++)

cin>>a[i];

sort(a+1,a+n+1);

for (i=1; i<=n; i++) cout<<a[i]<<" ";

return 0;

}

Bình luận (0)
Thu Hiền
Xem chi tiết
Bùi Minh Dũng
Xem chi tiết
nguyễn an phát
26 tháng 5 2021 lúc 21:13

program max_min;

uses crt;

var i,n,max,min:integer;

a:array[1..100]of integer;

begin

clrscr;

write('nhap n:');readln(n);

for i:=1 to n do

begin

write('a[',i,']=');readln(a[i]);

end;

writeln('day vua nhap la:');

for i:=1 to n do

write(a[i]:3);

writeln;

max:=a[1];min:=a[1];

for i:=1 to n do

begin

if a[i]>max then max:=a[i];

if a[i]<min then min:=a[i];

end;

writeln('gia tri lon nhat: ',max,' gia tri nho nhat: ',min);

readln;

end.

Bình luận (0)
Lê Thị Thu Phương
7 tháng 6 2021 lúc 20:59

uses crt;
var a:array[1..1000000] of longint;
      n,i,max,min:longint;
begin
      clrscr;
      write('Nhap so luong phan tu: '); readln(n);
      for i:=1 to n do 
            begin
                  write('Nhap phan tu thu ',i,': '); readln(a[i]);
            end;
      write('Day so vua nhap: ');
      for i:=1 to n do write(a[i],' '); writeln;
      max:=a[1];min:=a[1];
      for i:=2 to n do 
            begin
                  if a[i]>max then max:=a[i];
                  if a[i]<min then min:=a[i];
            end;
      writeln('GTLN: ',max);
      writeln('GTNN: ',min);
      readln;
end.

Bình luận (0)
Phan uyển nhi
Xem chi tiết
Nguyễn Lê Phước Thịnh
28 tháng 2 2022 lúc 9:49

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,k,t;

int main()

{

cin>>n>>k;

t=0;

for (i=1; i<=n; i++)

{

cin>>x;

if (x%k==0) t+=x;

}

cout<<t;

return 0;

}

Bình luận (0)